package com.source.hotelbath.utils.dialog;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.source.hotelbath.R;


/**
 * Created by linshixian on 2016/5/5.
 */
public class CustomerPromptDlg extends BaseDialog implements View.OnClickListener {

    private EditText mMessage;
    private TextView confirm, cancel;
    private DlgListener listener;
    private String msg;
    private Context context;
    public CustomerPromptDlg(Context context) {
        super(context, R.style.common_dlg);
        this.context=context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_num);
        TextView customer_prompt_title= (TextView) findViewById(R.id.customer_prompt_title);
        mMessage = (EditText) findViewById(R.id.customer_prompt_message);
        confirm = (TextView) findViewById(R.id.prompt_btn_confirm);
        cancel = (TextView) findViewById(R.id.prompt_btn_cancel);
        cancel.setOnClickListener(this);
        confirm.setOnClickListener(this);
        customer_prompt_title.setText(msg);
    }

    @Override
    public void onClick(View v) {
        if (v == cancel) {
            if (null != this.listener) {
                this.listener.cancel();
            }
            dismiss();
        } else if (v == confirm) {
            if (null != this.listener) {
                if (TextUtils.isEmpty(mMessage.getText().toString())){
                    Toast.makeText(context,"数量不能为空",Toast.LENGTH_SHORT).show();
                    return;
                }else {
                    this.listener.confirm(mMessage.getText().toString());
                }

            }
            dismiss();
        }
    }

    public void setListener(DlgListener listener) {
        this.listener = listener;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public interface DlgListener {
        public void confirm(String s);
        public void cancel();
    }
}
